/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.myapp.struts.Institucion;

import javax.servlet.http.*;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author Andreina Wilhelm
 */
public class AgregarInstitucionForm extends org.apache.struts.action.ActionForm {

    private String acronimo;
    private String nombre;
    private String sede;
    private String pais;
    
    public String getAcronimo() {
        return acronimo;
    }

    public void setAcronimo(String acronimo) {
        this.acronimo = acronimo.trim();
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre.trim();
    }

    public String getSede() {
        return sede;
    }

    public void setSede(String sede) {
        this.sede = sede.trim();
    }

    public String getPais() {
        return pais;
    }

    public void setPais(String pais) {
        this.pais = pais.trim();
    }

    

    /**
     *
     */
    public AgregarInstitucionForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    
    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
   @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        // Nueva instancia de ActionErrors
        ActionErrors errors = new ActionErrors();

        // validar campo de acronimo este lleno
        if (this.acronimo == null || this.acronimo.equals("")) {
            errors.add("err_acro", new ActionMessage("errors.required"));
        }

        // validar campo de nombre este lleno
        if (this.nombre == null || this.nombre.equals("")) {
            errors.add("err_nom", new ActionMessage("errors.required"));
        }
        
        // validar campo de sede este lleno
        if (this.sede == null || this.sede.equals("")) {
            errors.add("err_sede", new ActionMessage("errors.required"));
        }
        return errors;
    }
    
      
    @Override
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        // reset properties
        this.acronimo = "";
        this.nombre = "";
        this.sede = "";
        this.pais = "";
    }
}
